package com.aqie.appletserver.controller.baiduapi;

import com.aqie.appletserver.bean.request.VoiceRequest;
import com.aqie.appletserver.bean.response.VoiceResponse;
import com.aqie.appletserver.common.response.ResponseModel;
import com.aqie.appletserver.context.TokenContext;
import com.aqie.appletserver.service.IBaiduApiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("baidu/speech")
@Slf4j
public class SpeechRecognitionController {

    @Autowired
    private IBaiduApiService baiduApiService;

    // 语音识别极速版
    @GetMapping("speechToText")
    public ResponseModel<VoiceResponse> speechToText() throws IOException {
        VoiceRequest request = new VoiceRequest();
        VoiceResponse response  = baiduApiService.speechToText(request, TokenContext.getToken());
        log.info("{}",response.getResult());
        return ResponseModel.success(response);
    }





}
